var bookId;

//0. 解决长按时出现浏览器打开问题
document.oncontextmenu=function(e){
        e.preventDefault();
       };

//4. 根据年级科目教版获取视频列表
var getResourceList = function(){
    $.ajax({
        type: "GET",
        url: "../api/resource/list/" + bookId,
        contentType: "application/json",
        success: function (r) {
            if (r.code === 0) {
                console.log("获取视频列表");
                console.log(r);
                var book = r.book;
                var resourceList = r.resourceList;
                //设置年级科目教版册别
                if(book){
                    // 八年级>物理>认教版>下册>课时学习知识清单
                    $("#book-name").html(book.name)
                    $("#book-properties").html(book.grade.name + ">" + book.subject.name + ">" +book.version.name + ">" +book.fascicle.name)
                }
                if (!r.resourceList) {
		            $("#msg").html('<i class="icon icon-40 f20 f-green"></i>不存在该dpf资源');
                    $('#msg3').fadeIn();
                }else{
		            $('#msg3').fadeOut();
                    fillVideoData(resourceList);
                }
	    } else {
                $.toast(r.msg, "text");
            }
        }
    });
}

var fillVideoData = function(resourceList){
    var html = '';
    resourceList.forEach(function(value,index,array){
        html +='<a class="weui-cell weui-cell_access" href="./resource-detail.html?resourceId=' + value.id+'">';
        html +='<div class="weui-cell__hd"><p class="page-no"><b>'+value.pageNo+'</b><span style="font-size:10px">页</span></p></div>';
	html +='<div class="weui-cell__bd">';
        html +='<p >'+value.videoName+'</p>';
        html +='<p style="font-size: 13px;color: #888888;">'+value.unitName+'</p>';
        html +='</div>';
        html +='<div class="weui-cell__ft"></div>';
        html +='</a>';
    });
    $("#showVideoList").html(html);
}
